/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package uk.ac.aber.Blockmation.Actions;

import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;

/**
 *
 * @author alex
 */
public class ImageScaler extends Thread {
    
    
   private AffineTransform at = new AffineTransform();
   
   private BufferedImage imageOut;
   private BufferedImage imageIn;
   private int width;
   private int height;
   private Graphics2D g2;
   
   public ImageScaler(int width, int height) {
       //this.imageIn = imageIn;
       this.width = width;
       this.height = height;
       
       imageOut = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
       
   }
   
   @Override
   public void run() throws UnsupportedOperationException {
        at.setToScale(width, height);
        
        //imageOut = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
        g2 = imageOut.createGraphics();
        // draw newImage onto image using at transformation
        g2.drawImage(imageIn, at, null);
        g2.dispose();
   }
   
   public BufferedImage getImage() {
       return imageOut;
   }
   
   public void updateImage(BufferedImage imageIn) {
       this.imageIn = imageIn;
   }

}
